home *** CD-ROM | disk | FTP | other *** search
/ PC Media 7 / PC MEDIA CD07.iso / share / prog / cm / cmtqueue.cc < prev    next >
Encoding:
Text File  |  1994-09-06  |  1.2 KB  |  48 lines

  1. // CmTQueue.cc
  2. // -----------------------------------------------------------------
  3. // Compendium - C++ Container Class Library
  4. // Copyright (C) 1992-1994, Glenn M. Poorman, All rights reserved
  5. // -----------------------------------------------------------------
  6. // Queue template implementation.
  7. // -----------------------------------------------------------------
  8.  
  9.  
  10. // "CmTQueue" is the queue copy constructor.
  11. //
  12. template <class T> CmTQueue<T>::CmTQueue(const CmTQueue<T>& S)
  13.                                 : CmTLinkedList<T>(S)
  14. {}
  15.  
  16.  
  17. // "=" operator copies the contents of the input queue into this queue.
  18. //
  19. template <class T> CmTQueue<T>& CmTQueue<T>::operator=(const CmTQueue<T>& S)
  20. {
  21.   if (&S != this) copy(S);
  22.   return *this;
  23. }
  24.  
  25.  
  26. // "push" pushes the specified item onto the top of the queue.
  27. //
  28. template <class T> Bool CmTQueue<T>::push(const T& obj)
  29. {
  30.   return append(obj);
  31. }
  32.  
  33.  
  34. // "pop" removes the top item from the queue and returns a copy.
  35. //
  36. template <class T> T CmTQueue<T>::pop()
  37. {
  38.   return removeFirst();
  39. }
  40.  
  41.  
  42. // "peek" returns a copy of the top queue item.
  43. //
  44. template <class T> const T& CmTQueue<T>::peek() const
  45. {
  46.   return first();
  47. }
  48.